#define  _CRT_SECURE_NO_WARNINGS
#include "code.h"

void QueueInit(Que* ps)
{
	ps->head = ps->tail = NULL;
	ps->size = 0;
}

void QueuePush(Que* ps, QDateType* x)
{
	assert(ps);
	QNode* newnode = (QNode*)malloc(sizeof(QNode));
	if (newnode == NULL)
	{
		perror("malloc");
		exit(-1);
	}

	newnode->date = x;
	newnode->next = NULL;

	if (ps->tail == NULL)
	{
		ps->head = ps->tail = newnode;
	}
	else
	{
		ps->tail->next = newnode;
		ps->tail = newnode;
	}
}


void QueuePop(Que* ps)
{
	assert(ps);
	assert(!QueueEmpty(ps));

	if (ps->head->next == NULL)
	{
		free(ps->head);
		ps->head = ps->tail = NULL;
	}
	else
	{
		QNode* next = ps->head->next;
		free(ps->head);
		ps->head = next;
	}
	ps->size--;
}